﻿/*
ParallelPlatform Project - A web platform to distribute and share knowledge
Online Editor - An online tool to create and play animations
Copyright (C) 2011 Daniel Guerrero Martínez & Sergio Rodríguez Lumley

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package Classes{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	public class CDepth_Button extends MovieClip {
		
		public static const OVERALL:uint = 0;
		public static const OVERONE:uint = 1;
		public static const UNDERONE:uint = 2;
		public static const UNDERALL:uint = 3;
		
		private var selectFunction:Function;
		private var type:uint = 0;
		
		public function CDepth_Button(){
			this.buttonMode = true;
			this.useHandCursor = true;
			this.addEventListener(MouseEvent.CLICK, onClick);
		}
		
		/**
		Sets the type of the button
		@param t Type of the button
		*/
		public function setType(t:uint){
			type = t;
		}
		
		/**
		Gets the type of the button
		*/
		public function getType(){
			return type;
		}
		
		/**
		Sets the function to call after being selected
		@param f Function to call
		*/
		public function setParentFunction(f:Function){
			selectFunction = f;
		}
		
		/**
		  Function called when click event triggered
		 */
		public function onClick(evt:MouseEvent):void{
			if(selectFunction != null)
				selectFunction(type);
			else
				trace(this+" Warning: Using onClick function without seting Parent Function before!");
		}
		
	}
}
